﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TimeTravel.XnaLibrary.UI
{
	/// <summary>
	/// Represents a text container control used for drawing text to the screen.
	/// </summary>
	public abstract class TextContainer : Control
	{
		private string mText = string.Empty;
		private Color mTextColor = Color.White;
		private SpriteFont mFont;
		private Vector2 mTextSize;

		/// <summary>
		/// Gets or sets the text of the TextContainer.
		/// </summary>
		public virtual string Text
		{
			get { return mText; }
			set
			{
				mText = value;
				if (mFont != null)
					TextSize = mFont.MeasureString(mText);
			}
		}

		/// <summary>
		/// Gets the size of the text.
		/// </summary>
		public virtual Vector2 TextSize
		{
			get { return mTextSize; }
			protected set { mTextSize = value; }
		}
		
		/// <summary>
		/// Gets the Color used for drawing the text. Default value is Color.White.
		/// </summary>
		public virtual Color TextColor
		{
			get { return mTextColor; }
			set { mTextColor = value; }
		}

		/// <summary>
		/// Gets the font used for drawing the text.
		/// </summary>
		public virtual SpriteFont Font
		{
			get { return mFont; }
			set
			{
				mFont = value;
				TextSize = mFont.MeasureString(mText);
			}
		}
	}
}
